package com.erpanderp.wam.ac.model.service.travel;

import java.util.List;

import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

import com.erpanderp.wam.ac.model.entity.project.ProjectAssignmentDetail;
import com.erpanderp.wam.ac.model.entity.travel.Logistics;
import com.erpanderp.wam.ac.model.entity.travel.TravelExpenseAmount;
import com.erpanderp.wam.ac.model.entity.travel.TravelRequest;
import com.erpanderp.wam.util.CommonLookup;
import com.erpanderp.wam.util.HibernateUtil;

public class TravelExpenseAmountDAO {
	public List<TravelExpenseAmount> getTravelExpenseAmounts(Long travelRequestId) {
		List<TravelExpenseAmount> travelExpenseAmounts = null;
		try {
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			session.setFlushMode(FlushMode.COMMIT);
			Query query = session.createQuery("from TravelExpenseAmount tea where tea.travelRequest.travelRequestId = :travelRequestId");
			System.out.println(query == null);
			query.setCacheable(false).setLong("travelRequestId", travelRequestId);
			travelExpenseAmounts = (List<TravelExpenseAmount>) query.list();
			session.getTransaction().commit();
			return travelExpenseAmounts;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static void main(String q[]){
	}
}
